﻿/* Pomoho UI - Manage */
/*create by oneMax at 2008--10-29*/
Pui.manage = {
	onload:function(func){
		var oldload=window.onload;
		if(typeof window.onload!='function'){window.onload=func;}
		else{window.onload=function(){oldload;func();}}
	},
	checkIds:function(path){
		var arr=$(""+path+" input:checked").not(".all");
		var ids='';
		if(arr.length==0)
		{
			alert("您还没有选择");
			return
		}		
		for(var i=0;i<arr.length;i++){
			if(i==0) ids=arr.eq(i).attr("id")
			else ids+=','+arr.eq(i).attr("id");
		}
		//alert(ids)
		return ids;
	},
	tinyBlog:function(){
		this.selectTextarea();
		this.blogItem();
	},
	selectTextarea:function(){
		var text_default='写点什么吧...';
		$('#textUpdata').val(text_default).focus(function(){$(this).val()==text_default?$(this).css({'border':'1px solid #666','color':'#000'}).val(''):$(this).css({'border':'1px solid #666','color':'#000'})}).blur(function(){$(this).val()==''?$(this).css({'border':'1px solid #999','color':'#999'}).val(text_default):$(this).css({'border':'1px solid #999','color':'#999'})});
	},
	blogItem:function(){
		$('.lists li').hover(function(){$(this).addClass('hover').find('.action a').css('visibility','visible');},function(){$(this).removeClass('hover').find('.action a').css('visibility','hidden');});
		/*$('.blogtab li a').each(function(i){
			$(this).click(function(){$('.blogtab li a').removeClass('ac');$(this).addClass('ac');$('.post_con>ol').css('display','none');$('.post_con>ol:eq('+[i]+')').css('display','block');return false;});							 
			}
		);*/
	},
	MsgDiv:function(types,otitle,ocontent,func){
		
		if($("#Msger").length<=0){
			var str='';
			str+='<div style="display:none" class="floatDiv" id="Msger">';
			str+='	<h2></h2>';
			str+='	<div class="meat">';
			str+='	<div id="Msgs"></div>';
			if(types==2)
				str+='	<div id="Msgs_h"><button class="iBtn"><span>确定</span></button><button class="iBtn"><span>取消</span></button></div>';
			else str+='	<div id="Msgs_h"><button class="iBtn"><span>确定</span></button></div>';
			str+='	</div>';
			str+='	<div class="close"><input type="button" onclick="$(\'#Msger\').hideDiv()" /></div>';
			str+='</div>';
			$(str).appendTo("body");
		}else if(types==1&&$("#Msgs_h .iBtn").length>1){
			$("#Msgs_h .iBtn").eq(1).remove();
		}else if(types==2&&$("#Msgs_h .iBtn").length==1){
			$('<button class="iBtn"><span>取消</span></button>').appendTo("#Msgs_h");
		}
		
		$("#Msger h2").html(otitle);
		$("#Msgs").html(ocontent);
		$("#Msgs_h .iBtn").unbind();
		if(func){
			$("#Msgs_h .iBtn").eq(0).bind("click",function(){$("#Msger").hideDiv(func);});
			$("#Msgs_h .iBtn").eq(1).bind("click",function(){$("#Msger").hideDiv();});
		}else{
			$("#Msgs_h .iBtn").bind("click",function(){$("#Msger").hideDiv();});
		}
		$("#Msger").showDiv();
	}	
};


String.prototype.trim = function(){return this.replace(/(^[\s]*)|([\s]*$)/g,"")}

$.fn.dialog=function(a){
	
			var o={overlay:true,bgColor:'#000000',opacity:0.5};
			if(a)$.extend(o,a);
			  	if ($("#MarkID").length == 0) {
					var str = '';
					if ($.browser.msie) {
						str += '<iframe id="MarkID" style="display:none"></iframe>';
						$(str).appendTo("body");
						var cw = window.frames['MarkID'];
						cw.document.open();
						cw.document.write('<style type="text/css">body{background:'+o.bgColor+'}</style>');
						cw.document.close();
					}
					else {
						str = '<div id="MarkID"><iframe style="display:none"></iframe></div>';
						$(str).appendTo("body");
					}
											
				}
				
				var doc=document;
				var docElement=doc.documentElement;
				var sHeight=docElement.clientHeight;
				var dH=docElement.scrollHeight>sHeight?docElement.scrollHeight:sHeight;
				var scH=docElement.scrollTop>=0?(docElement.scrollTop+sHeight/2):sHeight;
				$("#MarkID").css({width:docElement.clientWidth,height:dH,position:'absolute',zIndex:9999,left:'0px',top:'0px',background:o.bgColor,opacity:o.opacity}).show();
				$(this).show();
				var h=scH-$(this)[0].clientHeight/2;
				var w=docElement.clientWidth/2-$(this)[0].clientWidth/2;
				//$(this).css({top:h,left:w,zIndex:10001}).show(500);
				$(this).css({top:'50%',left:'50%',marginTop:-$(this).height()/2,marginLeft:-$(this).width()/2,zIndex:10001}).show(500);
		}
//创建遮罩层

$.fn.hideDiv=function(fun){
		$(this).hide();  //关闭小层
		$('#MarkID').hide();//关闭大层
		if(fun) eval(fun);
	}
$.fn.showDiv=function (fun){
		$(this).dialog({bgColor:'#000000',opacity:0.12});
		if(fun) eval(fun);
	}
	
$.fn.check = function(mode){
   var mode = mode || 'on'; //default
    return this.each(function(){
        switch(mode){
            case 'on':
                this.checked = true;
                break;
            case 'off':
                this.checked = false;
                break;
            case 'toggle':
            	if(this.disabled==false)
                this.checked = !this.checked;
                break;
        }
    });
};
$.fn.checked=function(path){
	if ($(this)[0].checked==true||$(this)[0].checked==false) {
		var stat = $(this).attr('checked');
		if (stat == true) {
			$(path + " input:checkbox").check('on');
			this.checked = "true";
			return
		}
		else {
			$(path + " input:checkbox").check('off');
			this.checked = false;
			return
		}
	}else{
		var ele=($(this).children())?$(this).children():$(this);
		if(ele.html()=="全选"){
			$(path + " input:checkbox").check('on');
			ele.html("反选");
		}else if(ele.html()=="反选"){
			$(path + " input:checkbox").check('toggle');
			ele.html("全选");
		}
	}
	$(this).blur();	
}

Date.dayNames=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];Date.abbrDayNames=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];Date.monthNames=['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'];Date.abbrMonthNames=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];Date.firstDayOfWeek=1;Date.format='yyyy-mm-dd';Date.fullYearStart='20';(function(){function add(name,method){if(!Date.prototype[name]){Date.prototype[name]=method}};add("isLeapYear",function(){var y=this.getFullYear();return(y%4==0&&y%100!=0)||y%400==0});add("isWeekend",function(){return this.getDay()==0||this.getDay()==6});add("isWeekDay",function(){return!this.isWeekend()});add("getDaysInMonth",function(){return[31,(this.isLeapYear()?29:28),31,30,31,30,31,31,30,31,30,31][this.getMonth()]});add("getDayName",function(abbreviated){return abbreviated?Date.abbrDayNames[this.getDay()]:Date.dayNames[this.getDay()]});add("getMonthName",function(abbreviated){return abbreviated?Date.abbrMonthNames[this.getMonth()]:Date.monthNames[this.getMonth()]});add("getDayOfYear",function(){var tmpdtm=new Date("1/1/"+this.getFullYear());return Math.floor((this.getTime()-tmpdtm.getTime())/86400000)});add("getWeekOfYear",function(){return Math.ceil(this.getDayOfYear()/7)});add("setDayOfYear",function(day){this.setMonth(0);this.setDate(day);return this});add("addYears",function(num){this.setFullYear(this.getFullYear()+num);return this});add("addMonths",function(num){var tmpdtm=this.getDate();this.setMonth(this.getMonth()+num);if(tmpdtm>this.getDate())this.addDays(-this.getDate());return this});add("addDays",function(num){this.setTime(this.getTime()+(num*86400000));return this});add("addHours",function(num){this.setHours(this.getHours()+num);return this});add("addMinutes",function(num){this.setMinutes(this.getMinutes()+num);return this});add("addSeconds",function(num){this.setSeconds(this.getSeconds()+num);return this});add("zeroTime",function(){this.setMilliseconds(0);this.setSeconds(0);this.setMinutes(0);this.setHours(0);return this});add("asString",function(format){var r=format||Date.format;if(r.split('mm').length>1){r=r.split('mmmm').join(this.getMonthName(false)).split('mmm').join(this.getMonthName(true)).split('mm').join(_zeroPad(this.getMonth()+1))}else{r=r.split('m').join(this.getMonth()+1)}r=r.split('yyyy').join(this.getFullYear()).split('yy').join((this.getFullYear()+'').substring(2)).split('dd').join(_zeroPad(this.getDate())).split('d').join(this.getDate());return r});Date.fromString=function(s){var f=Date.format;var d=new Date('01/01/1970');if(s=='')return d;s=s.toLowerCase();var matcher='';var order=[];var r=/(dd?d?|mm?m?|yy?yy?)+([^(m|d|y)])?/g;var results;while((results=r.exec(f))!=null){switch(results[1]){case'd':case'dd':case'm':case'mm':case'yy':case'yyyy':matcher+='(\\d+\\d?\\d?\\d?)+';order.push(results[1].substr(0,1));break;case'mmm':matcher+='([a-z]{3})';order.push('M');break}if(results[2]){matcher+=results[2]}}var dm=new RegExp(matcher);var result=s.match(dm);for(var i=0;i<order.length;i++){var res=result[i+1];switch(order[i]){case'd':d.setDate(res);break;case'm':d.setMonth(Number(res)-1);break;case'M':for(var j=0;j<Date.abbrMonthNames.length;j++){if(Date.abbrMonthNames[j].toLowerCase()==res)break}d.setMonth(j);break;case'y':d.setYear(res);break}}return d};var _zeroPad=function(num){var s='0'+num;return s.substring(s.length-2)}})();
(function($){$.fn.extend({renderCalendar:function(s){var dc=function(a){return document.createElement(a)};s=$.extend({},$.fn.datePicker.defaults,s);if(s.showHeader!=$.dpConst.SHOW_HEADER_NONE){var headRow=$(dc('tr'));for(var i=Date.firstDayOfWeek;i<Date.firstDayOfWeek+7;i++){var weekday=i%7;var day=Date.dayNames[weekday];headRow.append(jQuery(dc('th')).attr({'scope':'col','abbr':day,'title':day,'class':(weekday==0||weekday==6?'weekend':'weekday')}).html(s.showHeader==$.dpConst.SHOW_HEADER_SHORT?day.substr(0,1):day))}};var calendarTable=$(dc('table')).attr({'cellspacing':2}).addClass('jCalendar').append((s.showHeader!=$.dpConst.SHOW_HEADER_NONE?$(dc('thead')).append(headRow):dc('thead')));var tbody=$(dc('tbody'));var today=(new Date()).zeroTime();today.setHours(12);var month=s.month==undefined?today.getMonth():s.month;var year=s.year||today.getFullYear();var currentDate=(new Date(year,month,1,12,0,0));var firstDayOffset=Date.firstDayOfWeek-currentDate.getDay()+1;if(firstDayOffset>1)firstDayOffset-=7;var weeksToDraw=Math.ceil(((-1*firstDayOffset+1)+currentDate.getDaysInMonth())/7);currentDate.addDays(firstDayOffset-1);var doHover=function(firstDayInBounds){return function(){if(s.hoverClass){var $this=$(this);if(!s.selectWeek){$this.addClass(s.hoverClass)}else if(firstDayInBounds&&!$this.is('.disabled')){$this.parent().addClass('activeWeekHover')}}}};var unHover=function(){if(s.hoverClass){var $this=$(this);$this.removeClass(s.hoverClass);$this.parent().removeClass('activeWeekHover')}};var w=0;while(w++<weeksToDraw){var r=jQuery(dc('tr'));var firstDayInBounds=s.dpController?currentDate>s.dpController.startDate:false;for(var i=0;i<7;i++){var thisMonth=currentDate.getMonth()==month;var d=$(dc('td')).text(currentDate.getDate()+'').addClass((thisMonth?'current-month ':'other-month ')+(currentDate.isWeekend()?'weekend ':'weekday ')+(thisMonth&&currentDate.getTime()==today.getTime()?'today ':'')).data('datePickerDate',currentDate.asString()).hover(doHover(firstDayInBounds),unHover);r.append(d);if(s.renderCallback){s.renderCallback(d,currentDate,month,year)}currentDate=new Date(currentDate.getFullYear(),currentDate.getMonth(),currentDate.getDate()+1,12,0,0)}tbody.append(r)}calendarTable.append(tbody);return this.each(function(){$(this).empty().append(calendarTable)})},datePicker:function(s){if(!$.event._dpCache)$.event._dpCache=[];s=$.extend({},$.fn.datePicker.defaults,s);return this.each(function(){var $this=$(this);var alreadyExists=true;if(!this._dpId){this._dpId=$.event.guid++;$.event._dpCache[this._dpId]=new DatePicker(this);alreadyExists=false}if(s.inline){s.createButton=false;s.displayClose=false;s.closeOnSelect=false;$this.empty()}var controller=$.event._dpCache[this._dpId];controller.init(s);if(!alreadyExists&&s.createButton){controller.button=$('<a href="#" class="dp-choose-date" title="选择日期'+$.dpText.TEXT_CHOOSE_DATE+'">'+$.dpText.TEXT_CHOOSE_DATE+'</a>').bind('click',function(){$this.dpDisplay(this);this.blur();return false});$this.after(controller.button)}if(!alreadyExists&&$this.is(':text')){$this.bind('dateSelected',function(e,selectedDate,$td){this.value=selectedDate.asString()}).bind('change',function(){if(this.value==''){controller.clearSelected()}else{var d=Date.fromString(this.value);if(d){controller.setSelected(d,true,true)}}});if(s.clickInput){$this.bind('click',function(){$this.trigger('change');$this.dpDisplay()})}var d=Date.fromString(this.value);if(this.value!=''&&d){controller.setSelected(d,true,true)}}$this.addClass('dp-applied')})},dpSetDisabled:function(s){return _w.call(this,'setDisabled',s)},dpSetStartDate:function(d){return _w.call(this,'setStartDate',d)},dpSetEndDate:function(d){return _w.call(this,'setEndDate',d)},dpGetSelected:function(){var c=_getController(this[0]);if(c){return c.getSelected()}return null},dpSetSelected:function(d,v,m,e){if(v==undefined)v=true;if(m==undefined)m=true;if(e==undefined)e=true;return _w.call(this,'setSelected',Date.fromString(d),v,m,e)},dpSetDisplayedMonth:function(m,y){return _w.call(this,'setDisplayedMonth',Number(m),Number(y),true)},dpDisplay:function(e){return _w.call(this,'display',e)},dpSetRenderCallback:function(a){return _w.call(this,'setRenderCallback',a)},dpSetPosition:function(v,h){return _w.call(this,'setPosition',v,h)},dpSetOffset:function(v,h){return _w.call(this,'setOffset',v,h)},dpClose:function(){return _w.call(this,'_closeCalendar',false,this[0])},_dpDestroy:function(){}});var _w=function(f,a1,a2,a3,a4){return this.each(function(){var c=_getController(this);if(c){c[f](a1,a2,a3,a4)}})};function DatePicker(ele){this.ele=ele;this.displayedMonth=null;this.displayedYear=null;this.startDate=null;this.endDate=null;this.showYearNavigation=null;this.closeOnSelect=null;this.displayClose=null;this.rememberViewedMonth=null;this.selectMultiple=null;this.numSelectable=null;this.numSelected=null;this.verticalPosition=null;this.horizontalPosition=null;this.verticalOffset=null;this.horizontalOffset=null;this.button=null;this.renderCallback=[];this.selectedDates={};this.inline=null;this.context='#dp-popup';this.settings={}};$.extend(DatePicker.prototype,{init:function(s){this.setStartDate(s.startDate);this.setEndDate(s.endDate);this.setDisplayedMonth(Number(s.month),Number(s.year));this.setRenderCallback(s.renderCallback);this.showYearNavigation=s.showYearNavigation;this.closeOnSelect=s.closeOnSelect;this.displayClose=s.displayClose;this.rememberViewedMonth=s.rememberViewedMonth;this.selectMultiple=s.selectMultiple;this.numSelectable=s.selectMultiple?s.numSelectable:1;this.numSelected=0;this.verticalPosition=s.verticalPosition;this.horizontalPosition=s.horizontalPosition;this.hoverClass=s.hoverClass;this.setOffset(s.verticalOffset,s.horizontalOffset);this.inline=s.inline;this.settings=s;if(this.inline){this.context=this.ele;this.display()}},setStartDate:function(d){if(d){this.startDate=Date.fromString(d)}if(!this.startDate){this.startDate=(new Date()).zeroTime()}this.setDisplayedMonth(this.displayedMonth,this.displayedYear)},setEndDate:function(d){if(d){this.endDate=Date.fromString(d)}if(!this.endDate){this.endDate=(new Date('12/31/2999'))}if(this.endDate.getTime()<this.startDate.getTime()){this.endDate=this.startDate}this.setDisplayedMonth(this.displayedMonth,this.displayedYear)},setPosition:function(v,h){this.verticalPosition=v;this.horizontalPosition=h},setOffset:function(v,h){this.verticalOffset=parseInt(v)||0;this.horizontalOffset=parseInt(h)||0},setDisabled:function(s){$e=$(this.ele);$e[s?'addClass':'removeClass']('dp-disabled');if(this.button){$but=$(this.button);$but[s?'addClass':'removeClass']('dp-disabled');$but.attr('title',s?'':$.dpText.TEXT_CHOOSE_DATE)}if($e.is(':text')){$e.attr('disabled',s?'disabled':'')}},setDisplayedMonth:function(m,y,rerender){if(this.startDate==undefined||this.endDate==undefined){return}var s=new Date(this.startDate.getTime());s.setDate(1);var e=new Date(this.endDate.getTime());e.setDate(1);var t;if((!m&&!y)||(isNaN(m)&&isNaN(y))){t=new Date().zeroTime();t.setDate(1)}else if(isNaN(m)){t=new Date(y,this.displayedMonth,1)}else if(isNaN(y)){t=new Date(this.displayedYear,m,1)}else{t=new Date(y,m,1)}if(t.getTime()<s.getTime()){t=s}else if(t.getTime()>e.getTime()){t=e}var oldMonth=this.displayedMonth;var oldYear=this.displayedYear;this.displayedMonth=t.getMonth();this.displayedYear=t.getFullYear();if(rerender&&(this.displayedMonth!=oldMonth||this.displayedYear!=oldYear)){this._rerenderCalendar();$(this.ele).trigger('dpMonthChanged',[this.displayedMonth,this.displayedYear])}},setSelected:function(d,v,moveToMonth,dispatchEvents){if(d<this.startDate||d>this.endDate){return}var s=this.settings;if(s.selectWeek){d=d.addDays(-(d.getDay()-Date.firstDayOfWeek+7)%7);if(d<this.startDate){return}}if(v==this.isSelected(d)){return}if(this.selectMultiple==false){this.clearSelected()}else if(v&&this.numSelected==this.numSelectable){return}if(moveToMonth&&(this.displayedMonth!=d.getMonth()||this.displayedYear!=d.getFullYear())){this.setDisplayedMonth(d.getMonth(),d.getFullYear(),true)}this.selectedDates[d.asString()]=v;this.numSelected+=v?1:-1;var selectorString='td.'+(d.getMonth()==this.displayedMonth?'current-month':'other-month');var $td;$(selectorString,this.context).each(function(){if($(this).data('datePickerDate')==d.asString()){$td=$(this);if(s.selectWeek){$td.parent()[v?'addClass':'removeClass']('selectedWeek')}$td[v?'addClass':'removeClass']('selected')}});$('td',this.context).not('.selected')[this.selectMultiple&&this.numSelected==this.numSelectable?'addClass':'removeClass']('unselectable');if(dispatchEvents){var s=this.isSelected(d);$e=$(this.ele);var dClone=Date.fromString(d.asString());$e.trigger('dateSelected',[dClone,$td,s]);$e.trigger('change')}},isSelected:function(d){return this.selectedDates[d.asString()]},getSelected:function(){var r=[];for(s in this.selectedDates){if(this.selectedDates[s]==true){r.push(Date.fromString(s))}}return r},clearSelected:function(){this.selectedDates={};this.numSelected=0;$('td.selected',this.context).removeClass('selected').parent().removeClass('selectedWeek')},display:function(eleAlignTo){if($(this.ele).is('.dp-disabled'))return;eleAlignTo=eleAlignTo||this.ele;var c=this;var $ele=$(eleAlignTo);var eleOffset=$ele.offset();var $createIn;var attrs;var attrsCalendarHolder;var cssRules;if(c.inline){$createIn=$(this.ele);attrs={'id':'calendar-'+this.ele._dpId,'class':'dp-popup dp-popup-inline'};$('.dp-popup',$createIn).remove();cssRules={}}else{$createIn=$('body');attrs={'id':'dp-popup','class':'dp-popup'};cssRules={'top':eleOffset.top+c.verticalOffset,'left':eleOffset.left+c.horizontalOffset};var _checkMouse=function(e){var el=e.target;var cal=$('#dp-popup')[0];while(true){if(el==cal){return true}else if(el==document){c._closeCalendar();return false}else{el=$(el).parent()[0]}}};this._checkMouse=_checkMouse;c._closeCalendar(true);$(document).bind('keydown.datepicker',function(event){if(event.keyCode==27){c._closeCalendar()}})}if(!c.rememberViewedMonth){var selectedDate=this.getSelected()[0];if(selectedDate){selectedDate=new Date(selectedDate);this.setDisplayedMonth(selectedDate.getMonth(),selectedDate.getFullYear(),false)}}$createIn.append($('<div></div>').attr(attrs).css(cssRules).append($('<h2></h2>'),$('<div class="dp-nav-prev"></div>').append($('<a class="dp-nav-prev-year" href="#" title="'+$.dpText.TEXT_PREV_YEAR+'">&lt;&lt;</a>').bind('click',function(){return c._displayNewMonth.call(c,this,0,-1)}),$('<a class="dp-nav-prev-month" href="#" title="'+$.dpText.TEXT_PREV_MONTH+'">&lt;</a>').bind('click',function(){return c._displayNewMonth.call(c,this,-1,0)})),$('<div class="dp-nav-next"></div>').append($('<a class="dp-nav-next-year" href="#" title="'+$.dpText.TEXT_NEXT_YEAR+'">&gt;&gt;</a>').bind('click',function(){return c._displayNewMonth.call(c,this,0,1)}),$('<a class="dp-nav-next-month" href="#" title="'+$.dpText.TEXT_NEXT_MONTH+'">&gt;</a>').bind('click',function(){return c._displayNewMonth.call(c,this,1,0)})),$('<div class="dp-calendar"></div>')).bgIframe());var $pop=this.inline?$('.dp-popup',this.context):$('#dp-popup');if(this.showYearNavigation==false){$('.dp-nav-prev-year, .dp-nav-next-year',c.context).css('display','none')}if(this.displayClose){$pop.append($('<a href="#" id="dp-close">'+$.dpText.TEXT_CLOSE+'</a>').bind('click',function(){c._closeCalendar();return false}))}c._renderCalendar();$(this.ele).trigger('dpDisplayed',$pop);if(!c.inline){if(this.verticalPosition==$.dpConst.POS_BOTTOM){$pop.css('top',eleOffset.top+$ele.height()-$pop.height()+c.verticalOffset)}if(this.horizontalPosition==$.dpConst.POS_RIGHT){$pop.css('left',eleOffset.left+$ele.width()-$pop.width()+c.horizontalOffset)}$(document).bind('mousedown.datepicker',this._checkMouse)}},setRenderCallback:function(a){if(a==null)return;if(a&&typeof(a)=='function'){a=[a]}this.renderCallback=this.renderCallback.concat(a)},cellRender:function($td,thisDate,month,year){var c=this.dpController;var d=new Date(thisDate.getTime());$td.bind('click',function(){var $this=$(this);if(!$this.is('.disabled')){c.setSelected(d,!$this.is('.selected')||!c.selectMultiple,false,true);if(c.closeOnSelect){c._closeCalendar()}if(!$.browser.msie){$(c.ele).trigger('focus',[$.dpConst.DP_INTERNAL_FOCUS])}}});if(c.isSelected(d)){$td.addClass('selected');if(c.settings.selectWeek){$td.parent().addClass('selectedWeek')}}else if(c.selectMultiple&&c.numSelected==c.numSelectable){$td.addClass('unselectable')}},_applyRenderCallbacks:function(){var c=this;$('td',this.context).each(function(){for(var i=0;i<c.renderCallback.length;i++){$td=$(this);c.renderCallback[i].apply(this,[$td,Date.fromString($td.data('datePickerDate')),c.displayedMonth,c.displayedYear])}});return},_displayNewMonth:function(ele,m,y){if(!$(ele).is('.disabled')){this.setDisplayedMonth(this.displayedMonth+m,this.displayedYear+y,true)}ele.blur();return false},_rerenderCalendar:function(){this._clearCalendar();this._renderCalendar()},_renderCalendar:function(){$('h2',this.context).html((new Date(this.displayedYear,this.displayedMonth,1)).asString($.dpText.HEADER_FORMAT));$('.dp-calendar',this.context).renderCalendar($.extend({},this.settings,{month:this.displayedMonth,year:this.displayedYear,renderCallback:this.cellRender,dpController:this,hoverClass:this.hoverClass}));if(this.displayedYear==this.startDate.getFullYear()&&this.displayedMonth==this.startDate.getMonth()){$('.dp-nav-prev-year',this.context).addClass('disabled');$('.dp-nav-prev-month',this.context).addClass('disabled');$('.dp-calendar td.other-month',this.context).each(function(){var $this=$(this);if(Number($this.text())>20){$this.addClass('disabled')}});var d=this.startDate.getDate();$('.dp-calendar td.current-month',this.context).each(function(){var $this=$(this);if(Number($this.text())<d){$this.addClass('disabled')}})}else{$('.dp-nav-prev-year',this.context).removeClass('disabled');$('.dp-nav-prev-month',this.context).removeClass('disabled');var d=this.startDate.getDate();if(d>20){var st=this.startDate.getTime();var sd=new Date(st);sd.addMonths(1);if(this.displayedYear==sd.getFullYear()&&this.displayedMonth==sd.getMonth()){$('.dp-calendar td.other-month',this.context).each(function(){var $this=$(this);if(Date.fromString($this.data('datePickerDate')).getTime()<st){$this.addClass('disabled')}})}}}if(this.displayedYear==this.endDate.getFullYear()&&this.displayedMonth==this.endDate.getMonth()){$('.dp-nav-next-year',this.context).addClass('disabled');$('.dp-nav-next-month',this.context).addClass('disabled');$('.dp-calendar td.other-month',this.context).each(function(){var $this=$(this);if(Number($this.text())<14){$this.addClass('disabled')}});var d=this.endDate.getDate();$('.dp-calendar td.current-month',this.context).each(function(){var $this=$(this);if(Number($this.text())>d){$this.addClass('disabled')}})}else{$('.dp-nav-next-year',this.context).removeClass('disabled');$('.dp-nav-next-month',this.context).removeClass('disabled');var d=this.endDate.getDate();if(d<13){var ed=new Date(this.endDate.getTime());ed.addMonths(-1);if(this.displayedYear==ed.getFullYear()&&this.displayedMonth==ed.getMonth()){$('.dp-calendar td.other-month',this.context).each(function(){var $this=$(this);var cellDay=Number($this.text());if(cellDay<13&&cellDay>d){$this.addClass('disabled')}})}}}this._applyRenderCallbacks()},_closeCalendar:function(programatic,ele){if(!ele||ele==this.ele){$(document).unbind('mousedown.datepicker');$(document).unbind('keydown.datepicker');this._clearCalendar();$('#dp-popup a').unbind();$('#dp-popup').empty().remove();if(!programatic){$(this.ele).trigger('dpClosed',[this.getSelected()])}}},_clearCalendar:function(){$('.dp-calendar td',this.context).unbind();$('.dp-calendar',this.context).empty()}});$.dpConst={SHOW_HEADER_NONE:0,SHOW_HEADER_SHORT:1,SHOW_HEADER_LONG:2,POS_TOP:0,POS_BOTTOM:1,POS_LEFT:0,POS_RIGHT:1,DP_INTERNAL_FOCUS:'dpInternalFocusTrigger'};$.dpText={TEXT_PREV_YEAR:'Previous year',TEXT_PREV_MONTH:'Previous month',TEXT_NEXT_YEAR:'Next year',TEXT_NEXT_MONTH:'Next month',TEXT_CLOSE:'Close',TEXT_CHOOSE_DATE:'',HEADER_FORMAT:'mmmm yyyy'};$.dpVersion='$Id: jquery.datePicker.js 84 2009-08-05 17:54:35Z kelvin.luck@gmail.com $';$.fn.datePicker.defaults={month:undefined,year:undefined,showHeader:$.dpConst.SHOW_HEADER_SHORT,startDate:undefined,endDate:undefined,inline:false,renderCallback:null,createButton:true,showYearNavigation:true,closeOnSelect:true,displayClose:false,selectMultiple:false,numSelectable:Number.MAX_VALUE,clickInput:false,rememberViewedMonth:true,selectWeek:false,verticalPosition:$.dpConst.POS_TOP,horizontalPosition:$.dpConst.POS_LEFT,verticalOffset:0,horizontalOffset:0,hoverClass:'dp-hover'};function _getController(ele){if(ele._dpId)return $.event._dpCache[ele._dpId];return false};if($.fn.bgIframe==undefined){$.fn.bgIframe=function(){return this}};$(window).bind('unload',function(){var els=$.event._dpCache||[];for(var i in els){$(els[i].ele)._dpDestroy()}})})(jQuery);
jQuery.fn.extend({
	data: function( key, value ){
		var parts = key.split(".");
		parts[1] = parts[1] ? "." + parts[1] : "";

		if ( value === undefined ) {
			var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);

			if ( data === undefined && this.length )
				data = jQuery.data( this[0], key );

			return data === undefined && parts[1] ?
				this.data( parts[0] ) :
				data;
		} else
			return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){
				jQuery.data( this, key, value );
			});
	},

	removeData: function( key ){
		return this.each(function(){
			jQuery.removeData( this, key );
		});
	}});
function showDesc(){
	$('#how_getM').click(function(){$('.gm_notes').toggle();});	
}

$(function()
            {
				//Date.format = 'yyyy-mm';
				$('.date-pick').datePicker({startDate:'1996-01-01'});
				showDesc();
				Pui.manage.tinyBlog();
            });
//出生年月，地区选择
Pui.manage.Select={
	init:function(){
		Pui.manage.onload(Pui.manage.Select.birth_choose);	
		document.getElementById('selProvince').onchange=Pui.manage.Select.changeProvince;
		document.getElementById('selCity').onchange=Pui.manage.Select.changeCity;
		document.getElementById('Year_1').onchange=Pui.manage.Select.changeBirther;
		document.getElementById('Month_1').onchange=Pui.manage.Select.changeBirther;
		document.getElementById('Day_1').onchange=Pui.manage.Select.changeBirther;
	},
	city_choose:function(){
		var sTemp = document.getElementById("hidCityID").value;			  
		sTemp = sTemp.substr(0,2);
		var obj1 = document.getElementById("selProvince");
		var obj2 = document.getElementById("selCity");
		Pui.manage.Select.refresh_obj(obj1, "UUD_PROVINCE",sTemp);		   						  
		Pui.manage.Select.select_obj(obj2, "UUD_CITY", obj1.value, document.getElementById("hidCityID").value);	
	},
	birth_choose:function(){
		var birthday = document.getElementById("hidBirthday").value;	
		Pui.manage.Select.init_calendar(1,birthday);
		if( birthday != null && birthday != "" ){		     
			document.getElementById("Year_1").value = birthday.substring(0,4);
			document.getElementById("Month_1").value = birthday.substring(5,7);
			document.getElementById("Day_1").value = birthday.substring(8,10);
		}else{
			document.getElementById("Year_1").value = "1980";
			document.getElementById("Month_1").value = "01";
			document.getElementById("Day_1").value = "01";
		}
		Pui.manage.Select.city_choose();
	},
	refresh_obj:function(obj, arr, value){
		if (!value) value = "0";	
		obj_opt = eval(obj);
		obj_arr = eval(arr);
		obj_opt.options.length = 1;
		obj_opt.options[0] = new Option("--请选择--", "0");
		for (i = 1; i <= obj_arr.length / 2; i ++)
		{
			obj_opt.options[i] = new Option(obj_arr[(i - 1) * 2 + 1], obj_arr[(i - 1) * 2]);
			if (value == obj_arr[(i - 1) * 2]){
				obj_opt.options[i].selected = true;
			}
		}
	},
	select_obj:function(obj, arr, filter, value){
		if (!value) value = "0";	
		obj_opt = eval(obj);
		obj_arr = eval(arr);
		obj_opt.options.length = 1;
		obj_opt.options[0] = new Option("--请选择--", "0");
		j = 1;
		for (i = 0; i < obj_arr.length / 2; i ++)
		{
			if (obj_arr[i * 2].substring(0, 2) == filter){
		   		obj_opt.options[j] = new Option(obj_arr[i * 2 + 1], obj_arr[i * 2]);
		   		if (value == obj_arr[i * 2]) obj_opt.options[j].selected = true;
		   		j ++;
			}
		}	
	},
	changeProvince:function(){
		var obj1= document.getElementById("selProvince");
		var obj2= document.getElementById("selCity");
		Pui.manage.Select.select_obj(obj2, "UUD_CITY", obj1.value, "");
		if(obj2.options.length>1)
		obj2.selectedIndex=1;
		document.getElementById("hidCityID").value = document.getElementById("selCity").value;	
	},
	changeCity:function(){
		document.getElementById("hidCityID").value = document.getElementById("selCity").value;	
	},
	changeBirther:function(){
		Pui.manage.Select.refresh_day(1);
		document.getElementById("hidBirthday").value = document.getElementById("Year_1").value + "-" + document.getElementById("Month_1").value + "-" + document.getElementById("Day_1").value;	
	},
	refresh_day:function(label){
		var day = document.getElementById('Day_' + label).value;	
		this.init_day(label, day);
	},
	init_calendar:function(label, date){
		if (null == date || 0 == date.length) Pui.manage.Select.init_calendar(label, '0', '0', '0');
		var year = date.split(new RegExp('[-.年月日]'))[0];
		var month = date.split(new RegExp('[-.年月日]'))[1];
		var day = date.split(new RegExp('[-.年月日]'))[2];
		this.init_year(label, year);
		this.init_month(label, month);
		this.init_day(label, day);		
	},
	init_year:function(label, year){
		var today = new Date()
		var current_year = today.getFullYear();
		Year = eval(document.getElementById('Year_' + label));
		Year.options.length = 1;
		Year.options[0] = new Option('--请选择--', '0');
		for (i = current_year, j = 1; i >= 1900; i --, j ++)
		{
			Year.options[j] = new Option(i, i);		
			if (year == i) Year.options[j].selected = true;
		}
	},
	init_month:function(label,month){
		var Month = eval(document.getElementById('Month_' + label));
		Month.options.length = 1;
		Month.options[0] = new Option('--请选择--', '0');
		for (var i = 1; i <= 12; i ++)
		{
			if ( i < 10 ){
				j = "0" + i;
			}
			else{
				j = i;
			}
			Month.options[i] = new Option(j, j);		
			if (month == j) Month.options[i].selected = true;
		}
	},
	init_day:function(label, day){
		var Day = eval(document.getElementById('Day_' + label));
		Day.options.length = 1;
		Day.options[0] = new Option('--请选择--', '0');
		var year = document.getElementById('Year_' + label).value;
		var month = document.getElementById('Month_' + label).value;
		var day_count = this.getdays(year, month);
		day_count = 0 == day_count? 31: day_count;	
		for (i = 1; i <= day_count; i ++)
		{
			if ( i < 10 ){
				j = "0" + i;
			}
			else{
				j = i;
			}
			Day.options[i] = new Option(j, j);		
			if (day == j) Day.options[i].selected = true;
		}	
	},
	getdays:function(year, month){
		if (1 > month || 12 < month) return 0;
		var days_in_month = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
		if ((year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0))){
			days_in_month.splice(1, 1, 29);
		}
		else{
			days_in_month.splice(1, 1, 28);
		}
		return days_in_month[month - 1];
	}
}
/*微博*/
Pui.Tinyblog={
	init:function(){
		this.changeShow();
		this.graytext();
	},
	changeShow:function(){
		var myA=$('#myUpdata .pubInfo .cos');
		var rel=$('#myUpdata .relayList');
		var gg=false;
		for(i=0;i<myA.length;i++){
			var obj = myA.eq(i);
			obj.click(function(e){
				var _obj=$(this);
				var index=_obj.parents('.pubInfo').find('.cos').index(_obj[0]);
				var ff=_obj.parents('.infoCon').find('.relayList').eq(index);
				if(ff.css('display')=='block'){ff.css('display','none');}
				else{rel.css('display','none');ff.css('display','block');}
				e.preventDefault();
			})
		}
		var inTxt=$('#myUpdata .infoCon .relayList .inputTxt');
		$('#myUpdata .w_close').click(function(){$('#myUpdata .relayList').css('display','none');inTxt.removeClass('graytext');})
	},
	graytext:function(){
		var inTxt=$('#myUpdata .infoCon .relayList .inputTxt');
		inTxt.click(function(){
			inTxt.addClass('graytext');
		})
	}
}
$(function(){Pui.Tinyblog.init();});
